home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / tdsnap.arc / STAYRES.PAK next >
Encoding:
Text File  |  1986-09-28  |  4.4 KB  |  195 lines

  1. (*
  2.  
  3. General purpose  TSR code,  placed in  the public  domain by  Lane H.  Ferris as
  4. STAYRES3.ARC.  This file is STAYRES.320 plus include files with comments,  blank
  5. lines and redundant spaces removed.  See the original STAYRES code for    comments
  6. and explanation of  what's going on.   Pascal source compression  done by Saxman
  7. Software COMPRESS.COM utility.
  8.  
  9. Look for comments "User Varibles" or "User Code".  These mark places one is most
  10. likely to add code  for custom TSR routines.   Important: Compile this to  a COM
  11. file with  mAximum free  memory around    300-400.  If  you get "memory allocation
  12. error" or "cannot load COMMAND.COM", you probably forgot to do this.
  13.  
  14. *)
  15. {$C-}
  16. Program STAYRES;
  17. const
  18.  Our_Char = 113;
  19.  Quit_Key = 119;
  20.  User_Int = $67;
  21.  Kybrd_Int = $16;
  22. Type
  23.  Regtype = record Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Flags:integer end;
  24.  HalfRegtype = record Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh:byte end;
  25. Const
  26.  Regs : regtype = (Ax:0;Bx:0;Cx:0;Dx:0;Bp:0;Si:0;Di:0;Ds:0;Es:0;Flags:0);
  27.  OurDseg : integer = 0;
  28.  OurSseg : integer = 0;
  29.  DosSseg : integer = 0;
  30.  Inuse : Boolean = false;
  31.  User_IntIP : integer = 0;
  32.  User_IntCs : integer = 0;
  33. Var
  34.  SaveRegs : regtype;
  35.  HalfRegs : halfregtype absolute regs;
  36.  Terminate_flag : boolean ;
  37.  Keychr : char ;
  38. (*========================= Begin User Variables ===========================*)
  39. (*========================== End User Variables ============================*)
  40. Procedure Stay_Xit;
  41. Begin
  42.  Writeln ('StayRes Returning memory to DOS') ;
  43.  SaveRegs.Ax := $35 shl 8 + User_Int;
  44.  MsDos(SaveRegs);
  45.  SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
  46.  SaveRegs.Ds := SaveRegs.Es;
  47.  SaveRegs.Dx := SaveRegs.Bx;
  48.  MsDos(SaveRegs);
  49.  MemW[$00:User_Int * 4] := 0 ;
  50.  MemW[$00:User_Int * 4 + 2] :=0;
  51.  Saveregs.Ax := $49 shl 8 + 0 ;
  52.  Saveregs.Es := MemW[Cseg:$2C] ;
  53.  MsDos( Saveregs ) ;
  54.  Saveregs.Ax := $49 shl 8 + 0 ;
  55.  Saveregs.Es := Cseg ;
  56.  MsDos( Saveregs ) ;
  57.  Intr($20,Regs) ;
  58. End;
  59. Procedure Process_Intr;
  60. Begin
  61.  Inline (
  62.  $80/$FC/$00/
  63.  $74/$07/
  64.  $5D/$5D/
  65.  $2E/
  66.  $FF/$2E/User_IntIP/
  67.  $FA /
  68.  $55/
  69.  $BD/Regs/
  70.  $2E/$89/$46/$00/
  71.  $2E/$89/$5E/$02/
  72.  $2E/$89/$4E/$04/
  73.  $2E/$89/$56/$06/
  74.  $2E/$8F/$46/$08/
  75.  $2E/$89/$76/$0A/
  76.  $2E/$89/$7E/$0C/
  77.  $2E/$8C/$5E/$0E/
  78.  $2E/$8C/$46/$10/
  79.  $9C/
  80.  $2E/$8F/$46/$12/
  81.  $2E/$80/$3E/Inuse/$01/
  82.  $74/$57/
  83.  $2E/$8C/$16/DosSSeg/
  84.  $8C/$D6/
  85.  $8E/$C6/
  86.  $2E/$8E/$16/OurSSeg/
  87.  $2E/$8E/$1E/OurDseg/
  88.  $2E/$3B/$36/OurSSeg/
  89.  $89/$E6/
  90.  $74/$05/
  91.  $3E/$8B/$36/$74/$01/
  92.  $87/$F4/
  93.  $2E/$FF/$76/$00/
  94.  $2E/$FF/$76/$02/
  95.  $2E/$FF/$76/$04/
  96.  $2E/$FF/$76/$06/
  97.  $2E/$FF/$76/$0A/
  98.  $2E/$FF/$76/$0C/
  99.  $2E/$FF/$76/$0E/
  100.  $2E/$FF/$76/$10/
  101.  $B9/>$0028/
  102.  $26/$FF/$34/
  103.  $46/$46/
  104.  $E2/$F9/
  105.  $2E/$8E/$16/OurSSeg/
  106.  $56/
  107.  $2E/$8C/$5E/$0E/
  108.  $FB
  109.  ) ;
  110.  Intr (User_Int, Regs);
  111.  If (Halfregs.Ah = Quit_Key) then
  112.  stay_xit
  113.  else
  114.  If (Halfregs.Ah = Our_Char)
  115.  then if (not InUse) then
  116.  Begin
  117.  InUse := true;
  118. (*============================ Begin User Code =============================*)
  119. (*============================= End User Code ==============================*)
  120.  Regs.Ax := $1D00;
  121.  InUse := false;
  122.  End;
  123.  inline(
  124.  $BD/Regs/
  125.  $2E/$8B/$46/$00/
  126.  $2E/$8B/$5E/$02/
  127.  $2E/$8B/$4E/$04/
  128.  $2E/$8B/$56/$06/
  129.  $2E/$8B/$76/$0A/
  130.  $2E/$8B/$7E/$0C/
  131.  $2E/$8E/$5E/$0E/
  132.  $2E/$8E/$46/$10/
  133.  $2E/$FF/$76/$12/
  134.  $9D/
  135.  $2E/$80/$3E/Inuse/$01/
  136.  $74/$23/
  137.  $FA /
  138.  $5E/
  139.  $B9/>$0028/
  140.  $2E/$8E/$06/DosSSeg/
  141.  $4E/$4E/
  142.  $26/$8F/$04/
  143.  $E2/$F9/
  144.  $89/$F5/
  145.  $07/
  146.  $1F/
  147.  $5F/
  148.  $5E/
  149.  $5A/
  150.  $59/
  151.  $5B/
  152.  $44/$44/
  153.  $89/$EC/
  154.  $2E/$8E/$16/DosSSeg/
  155.  $5D/
  156.  $BD/Regs/
  157.  $2E/$FF/$76/$12/
  158.  $9D/
  159.  $5D/
  160.  $FB/
  161.  $CA/$02/$00
  162.  );
  163. End;
  164. Begin
  165.  InUse := false;
  166.  OurDseg:= Dseg;
  167.  OurSseg:= Sseg;
  168.  Terminate_Flag := false ;
  169.  SaveRegs.Ax := $35 shl 8 + User_Int;
  170.  Intr($21,SaveRegs);
  171.  if SaveRegs.Es <> $00 then
  172.  WriteLn ('Interrupt in use -- can''t install StayRes as Resident Code')
  173.  else
  174.  begin
  175.  SaveRegs.Ax := $35 shl 8 + Kybrd_Int;
  176.  Intr($21,SaveRegs);
  177.  SaveRegs.Ax := $25 shl 8 + User_Int;
  178.  SaveRegs.Ds := SaveRegs.Es;
  179.  SaveRegs.Dx := SaveRegs.Bx;
  180.  Intr($21,SaveRegs);
  181.  SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
  182.  SaveRegs.Ds := Cseg;
  183.  SaveRegs.Dx := Ofs(Process_Intr);
  184.  Intr ($21,SaveRegs);
  185.  User_IntIp := MemW[0:User_Int * 4 ];
  186.  User_IntCs := MemW[0:User_Int * 4 +2];
  187.  Writeln('  Program Memory Resident.');
  188.  WriteLn('  Press Alt-F10 to activate.');
  189.  WriteLn('  Press Ctrl-Home to un-install.');
  190.  SaveRegs.Ax := $31 shl 8 + 0 ;
  191.  SaveRegs.Dx := MemW [Cseg-1:0003] ;
  192.  Intr ($21,SaveRegs);
  193.  end;
  194. end.
  195.